﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ewk.Math.Algebra.UnitTests
{
    [TestClass]
    public class VectorInt32UnitTests : VectorUnitTestsBase<int>
    {
        #region Distance
        [TestMethod]
        public void VectorInt32_Distance_returns_the_Zero_representation_of_a_Computable_for_two_Vectors_in_3D_that_are_equal()
        {
            var vector1 = CreateVector(1, 2, 3);
            var vector2 = CreateVector(1, 2, 3);

            var result = Vector<int>.Distance(vector1, vector2);

            Assert.AreEqual(0, result.Value);
        }

        [TestMethod]
        public void VectorInt32_Distance_returns_the_Zero_representation_of_a_Computable_for_two_Vectors_in_10D_that_are_equal()
        {
            var vector1 = CreateVector(11, 12, 13, 10, 14, 16, 18, 17, 15, 19);
            var vector2 = CreateVector(11, 12, 13, 10, 14, 16, 18, 17, 15, 19);

            var result = Vector<int>.Distance(vector1, vector2);

            Assert.AreEqual(0, result.Value);
        }

        [TestMethod]
        public void VectorInt32_Distance_returns_the_norm_of_the_non_null_Vector_when_one_of_the_two_Vectors_is_null()
        {
            var vector1 = CreateVector(1, 2, 2);

            var result1 = Vector<int>.Distance(vector1, null);
            var result2 = Vector<int>.Distance(null, vector1);

            Assert.AreEqual(3, result1.Value);
            Assert.AreEqual(3, result2.Value);
        }

        [TestMethod]
        public void VectorInt32_Distance_returns_the_norm_of_the_Non_Zero_Vector_when_one_of_the_two_Vectors_is_the_Zero_Vector()
        {
            var vector1 = CreateVector(1, 2, 2);

            var result1 = Vector<int>.Distance(vector1, Vector<int>.Zero(3));
            var result2 = Vector<int>.Distance(Vector<int>.Zero(3), vector1);

            Assert.AreEqual(3, result1.Value);
            Assert.AreEqual(3, result2.Value);
        }

        [TestMethod]
        public void VectorInt32_Distance_returns_the_distance_between_two_Vectors()
        {
            var vector1 = CreateVector(10, 34, 5);
            var vector2 = CreateVector(9, 32, 3);

            var result1 = Vector<int>.Distance(vector1, vector2);
            var result2 = Vector<int>.Distance(vector2, vector1);

            Assert.AreEqual(3, result1.Value);
            Assert.AreEqual(3, result2.Value);
        }

        #endregion

        [TestMethod]
        public void VectorInt32_Add_performs_an_add_to_each_element()
        {
            var vector1 = CreateVector(1, 2, 3);
            const int factor = 2;

            vector1.Add(factor);

            Assert.AreEqual(3, vector1[0].Value);
            Assert.AreEqual(4, vector1[1].Value);
            Assert.AreEqual(5, vector1[2].Value);
        }

        [TestMethod]
        public void VectorInt32_Norm_computes_the_euclidian_norm_of_the_vector()
        {
            var vector1 = CreateVector(3, 4);
            var norm = vector1.Norm;

            Assert.AreEqual(5, norm.Value);
        }
    }
}
